<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>欢迎光临 Music Store</title>
<link type="text/css" rel="Stylesheet"
	href="${pageContext.request.contextPath }/style/front.css" />
<script src="${pageContext.request.contextPath}/script/jquery-1.10.2.js"></script>
<script src="${pageContext.request.contextPath}/script/jquery.validate.js"></script>
<script>
	$(function(){
		$("form").validate({
			rules:{
				"album.title":{
					required:true
				},
				"album.artist":{
					required:true
				},
				"album.price":{
					required:true
				},
				"album.dateReleased":{
					required:true
				}
			},
			messages:{
				"album.title":{
					required:"请输入唱片标题"
				},
				"album.artist":{
					required:"请输入歌手名称"
				},
				"album.price":{
					required:"请输入单价"
				},
				"album.dateReleased":{
					required:"请输入发行日期"
				}
			}
		});
	});
</script>
<style>
#title {
	width: 950px;
	margin: 10px auto;
	height: 40px;
	background-color: white;
}

#title h3 {
	line-height: 40px;
	margin: 0px 30px;
	font-size: 18px;
}

#main {
	width: 930px;
	margin: 0px auto;
}

#main table {
	margin: 20px 50px;
}

#main td {
	padding: 0px 0px 5px 5px;
}

input[type=text] {
	width: 200px;
}

option {
	width: 185px;
}
</style>
</head>

<body>
	<div id="wrapper">
		<s:action name="header" executeResult="true" namespace="/admin"></s:action>
		<div id="content">
			<div id="title">
				<h3>添加商品</h3>
			</div>
			<div id="main">
				<form action="editAlbum" method="post" id="form">
					<table>
						<tr>
							<td>唱片名称:</td>
							<input type="hidden" name="album.id"
								value="${album.id }" />
							<td><input type="text" name="album.title"
								value="${album.title }" /></td>
						</tr>
						<tr>
							<td>唱片封面:</td>
							<td><input type="file" name="image" /></td>
						</tr>
						<tr>
							<td>歌手:</td>
							<td><input type="text" name="album.artist"
								value="${album.artist }" /></td>
						</tr>
						<tr>
							<td>唱片分类:</td>
							<td><select name="album.genre.id">
									<c:forEach items="${genreList }" var="g">
										<c:if test="${album.genre.id==g.id }">
											<option value="${g.id }" selected="selected">${g.name }</option>
										</c:if>
										<c:if test="${album.genre.id!=g.id }">
											<option value="${g.id }">${g.name }</option>
										</c:if>
									</c:forEach>
							</select></td>
						</tr>
						<tr>
							<td>单价:</td>
							<td><input type="text" name="album.price"
								value="${album.price }" /></td>
						</tr>
						<tr>
							<td>发行日期:</td>
							<td><input type="text" name="album.dateReleased"
								value="${album.dateReleased }" /></td>
						</tr>
						<tr>
							<td>唱片详细信息：</td>
							<td><textarea cols="40" rows="5" name="album.description">${album.description }</textarea></td>
						</tr>
						<tr>
							<td></td>
							<td><input type="submit" value="保存" /></td>
						</tr>
					</table>
				</form>
			</div>
			<div class="clearBoth"></div>
		</div>
		<%@ include file="../shared/back.jsp"%>
	</div>
</body>
</html>
